package com.kungfuhacking.wristbandpro.location.presenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.kungfuhacking.wristbandpro.R;
import com.kungfuhacking.wristbandpro.location.bean.AreaListEntity;

import java.util.List;

/**
 * 安全区域
 * Created by Aaron on 17/5/5.
 */

public class SafeAreaAdapter extends RecyclerView.Adapter<SafeAreaAdapter.MyViewHolder> {

    private Context context;
    private List<AreaListEntity> AreaListEntitys;

    public SafeAreaAdapter(Context context, List<AreaListEntity> AreaListEntitys) {
        this.context = context;
        this.AreaListEntitys = AreaListEntitys;
    }

    public void setAreaListEntitys(List<AreaListEntity> AreaListEntitys) {
        this.AreaListEntitys = AreaListEntitys;
    }

    @Override
    public SafeAreaAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(
                LayoutInflater.from(context).inflate(R.layout.item_affection_num, parent,
                        false));
    }

    @Override
    public void onBindViewHolder(SafeAreaAdapter.MyViewHolder holder, int position) {
        holder.tv_left_item.setText(AreaListEntitys.get(position).getAreaName());
        holder.tv_right_item.setText(AreaListEntitys.get(position).getRadius() + "m");
    }

    @Override
    public int getItemCount() {
        if (AreaListEntitys != null)
            return AreaListEntitys.size();
        else
            return 0;
    }

    class MyViewHolder extends RecyclerView.ViewHolder {

        TextView tv_left_item;
        TextView tv_right_item;

        MyViewHolder(View view) {
            super(view);
            tv_left_item = (TextView) view.findViewById(R.id.tv_left_item);
            tv_right_item = (TextView) view.findViewById(R.id.tv_right_item);
        }
    }
}